package com.gpms.action.base;

import java.io.FileInputStream;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;

import org.apache.struts2.ServletActionContext;

public class DoloadFileAction {
	private String inputPath;
	private String fileName;

	public void setInputPath() {
		this.inputPath = (String)ServletActionContext.getRequest().getParameter("url");
	}
	public void setFileName() {
		String name = (String)ServletActionContext.getRequest().getParameter("url");
		name = name.substring(name.lastIndexOf("/")+1, name.length());
		try {
			this.fileName = new String(name.getBytes(), "ISO8859-1");
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		} 
	}
	public String getFileName() {
		return fileName;
	}
	public InputStream getDownFile() throws Exception
	{
		this.setInputPath();
		this.setFileName();
		return ServletActionContext.getServletContext().getResourceAsStream(inputPath);
	}
	public String execute() throws Exception
	{
		return "success";
	}

}
